const Router = require('koa-router');
const router = new Router();

// 验证身份
const { authMiddleware, authorizeAdmin } = require('../middlewares/authMiddleware')
// 业务层
const {
  getVideosByCourseId,
  createVideo,
  getVideoById,
  updateVideo,
  deleteVideo,
  deleteVideos,
} = require('../controllers/videoController')

// 获取课程下的所有视频
router.get('/:courseId/videos',authMiddleware, getVideosByCourseId);

// 创建视频
router.post('/:courseId/videos', authMiddleware, authorizeAdmin, createVideo);

// 获取单个视频
router.get('/:courseId/videos/:videoId',authMiddleware, getVideoById);

// 更新视频
router.put('/:courseId/videos/:videoId', authMiddleware, authorizeAdmin, updateVideo);

// 删除视频
router.delete('/:courseId/videos/:videoId', authMiddleware, authorizeAdmin, deleteVideo);

// 批量删除视频
router.post('/:courseId/videos/batch-delete', authMiddleware, authorizeAdmin, deleteVideos);

module.exports = router;
